-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add EngineApiBoundary cop #6
Conversation
1bbf790
to
57c8d11
Compare
57c8d11
to
0c77725
Compare
0c77725
to
d6f07ba
Compare
Can I use this feature to prevent boundaries across multiple directories? For example, if a project included an engines directory (rails gems) and a gems directory (non-rails gems).
As to why you may want to have both gems and engines seperated, see: Excited about this cop. |
Interesting. The directory tree of our codebase is similar, with top-level This cop will prevent code in the gems from accessing code in engines. Indeed, it prevents any code outside the engine from accessing code in the engine. It will not, however, prevent engines from directly accessing code in gems. Nor will it prevent either gems or engines from accessing "main app" models. To prevent engines from accessing "main app" models, you can use this cop: #5. It may be possible to support both of these cops to support gems, or to create new gem-focused cops. Would you want to define an |
This cop enforces modular isolation of Rails Engines. It allows engines to define an API surface in an internal
api/
directory. Code outside the engine is only allowed to interact with the engine through that API surface. For more details, check out in the class comments inengine_api_boundary.rb
.Whereas
Flexport/GlobalModelAccessFromEngine
prevents an engine from reaching out into the globalapp/models
, this cop prevents any code outside an engine from reaching in to access that engine.A change in the main RuboCop repo is a prerequisite for this PR: "Allow cops to invalidate results cache" (rubocop/rubocop#7496).